<template>
  <!-- vue3.0配置 -->
  <router-view v-slot="{ Component }">
    <keep-alive>
      <component
        :is="Component"
        :key="$route.name"
        v-if="$route.meta.keepAlive"
      />
    </keep-alive>
    <component
      :is="Component"
      :key="$route.name"
      v-if="!$route.meta.keepAlive"
    />
  </router-view>
</template>

<script setup lang="ts">
import { getToken } from '@/service/cookie'
import { useStore } from 'vuex'
import { onMounted } from 'vue'
const store = useStore()
onMounted(() => {
  if (!getToken('userId')) {
    if (getToken('token') && (getToken('bindId') === undefined || getToken('bindId') === 'undefined' || !getToken('bindId'))) {
      store.dispatch('fetchUserInfo')
    }
  }
})

</script>

<style lang="less">
@media (min-width: 750px) {
  #app {
    width: 375px;
    height: 568px;
    margin:0 auto;
  }
}
</style>
